<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="ww" uri="webwork" %>
	<input type="hidden" id="pwdLevelJs" name="pwdLevelJs" value="<ww:property value='pwdLevel'/>"/>
	<input type="hidden" id="realpwd" name="realpwd" value="<ww:property value='#session.sUser.password'/>"/>
	<input type="hidden" id="realreviewpwd" name="realreviewpwd" value="<ww:property value='#session.sUser.reviewPwd'/>"/>
	
	<%--<div class="table_list_tab">
		<ww:link name="loginPwdDivTab" funcode="acl_user/updPasswordSetting" caption="修改登录密码"  onclick="showLoginPwdDivTab();"  href="javascript:;"></ww:link>
		<ww:link name="reviewPwdDivTab" funcode="acl_user/updReviewPwdSetting" caption="修改签章密码"  onclick="showReviewPwdDivTab();"  href="javascript:;"></ww:link>
		<ww:link name="personalDataTab" funcode="acl_user/updPersonalSetting" caption="修改个人资料"  onclick="showPersonalDataTab();"  href="javascript:;"></ww:link>
	</div>--%>
	
		<form class="form-horizontal form-validate" id="updPasswordSetting_form" method="post" action="updPasswordSetting.action"  onsubmit="return $action.submit(this);">
			<input type="hidden" id="pwdLevel" name="pwdLevel" value="<ww:property value='pwdLevel'/>"/>
			<input type="hidden" id="newPasswordTr" name="newPasswordTr" />
			<input type="hidden" id="repeatNewPasswordTr" name="repeatNewPasswordTr" />
			<input type="hidden" id="passwordTr" name="passwordTr" />
			<div class="control-group">
				<label class="control-label" ><span class="required">*</span>原密码</label>
				<div class="controls">
					<input type="password" placeholder="请输入原密码"  class="input-large required" onfocus="passwordfocus()" onblur="passwordblur()" id="password" name="password" value="" onKeyUp="onPasswordMouseMove();" maxlength="50"/>
					<font id="PasswordShowEm" color="red"></font>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><span class="required">*</span>新密码</label>
				<div class="controls">
					<input type="password" placeholder="请输入6-16位新密码" value="" class="input-large required" id="newPassword" name="newPassword" maxlength="50" onkeyup="pwStrength(this.value)" onblur="hiddenTable()" onfocus="pwStrength(this.value)"> 
					<font id="newPasswordShowEm" color="red" style="left: 16px;position: relative;"></font>
					<table  style="display:none" id="hiddenTable" border="0" cellpadding="0" cellspacing="0" class="passmsg">
						<tr> 
							<td id="strength_L" class="l">弱</td>
							<td id="strength_M" class="m">中</td> 
							<td id="strength_H" class="h">强</td> 
						</tr>
					</table>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><span class="required">*</span>确认密码</label>
				<div class="controls">
					<input type="password" placeholder="请再次输入新密码" class="input-large required" value="" name="repeatNewPassword" maxlength="50"
						id="repeatNewPassword" onKeyUp="hiddenTable()" onblur="onRepeatNewPasswordMouseMove();" onfocus="repeatNewPasswordfocus()">
						&nbsp;&nbsp;&nbsp;&nbsp;<font id="repeatPasswordShow1" color="red"></font>
				</div>
			</div>
			<div class="set-btn" data-spy="affix" data-offset-top="200">
				<a class="save btn" href="javascript:;" onclick="submitPwd()" style="border: 0;background-color: #317caf;height: 21px;width: 26px">保存</a>
			</div>
		</form>
	

<script>

var pwdLevel = $("#pwdLevelJs").val();
var password = true;
var loginStatusPwd = 1;
var loginStatusRe = 1;
var loginStatusPe = 1;

$(document).ready(function() { 
	$("#loginPwdDivTab").attr("class","active");
    $("#reviewPwdDivTab").attr("class","");
    $("#personalDataTab").attr("class","");
}); 

function updReviewPwd(data){
	//debugger;
	navTabAjaxDone(data);
	if(data.result!=0){ 
		  $("#reviewPwd").val("");
		  $("#newReviewPwd").val("");
		  $("#repeatNewReviewPwd").val("");
		  $("#newReviewPasswordShowEm").html("");
		  $("#repeatNewReviewPwdFont").html("");
		  $css.alert(data.msg);
	}else{
		$css.tip(data.msg);
		$.cssTab.focus().parent().parent().cssTab('closeCurrent');
	}
}
function updPassword(data){
	navTabAjaxDone(data);
	if(data.result!=0){ 
		  $("#password").val("");
		  $("#newPassword").val("");
		  $("#repeatNewPassword").val("");
		  $("#newPasswordShowEm").html("");
		  $("#repeatPasswordShow1").html("");
		  $css.alert(data.msg);
		  
	}else{
		$css.tip(data.msg);
		$.cssTab.focus().parent().parent().cssTab('closeCurrent');
	}
}
function submitPwd(){
	if($("#newPasswordShowEm").html() == "" && $("#repeatPasswordShow1").html() == ""){
		$("#passwordTr").val(md5($("#password").val()));
		$("#newPasswordTr").val(md5($("#newPassword").val()));
		$("#repeatNewPasswordTr").val(md5($("#repeatNewPassword").val()));
		$("#updPasswordSetting_form").submit();
	}else{
		loginStatusPwd = 2;
		if($("#newPasswordShowEm").html() != ""){
			$("#newPassword").focus();
		}else if($('#PasswordShowEm').html() != ""){
			$("#password").focus();
		}else if($("#repeatPasswordShow1").html() != ""){
			$("#repeatNewPassword").focus();
		}
	}
}

function CharMode(iN){
	if (iN>=48 && iN <=57) return 1; 
	if (iN>=65 && iN <=90) return 2; 
	if (iN>=97 && iN <=122) return 4; 
} 
function bitTotal(num){ 
	modes=0; 
	for (i=0;i<4;i++){
		if (num & 1) modes++; 
		num>>>=1; 
	} 
	return modes; 
} 
function checkStrong(sPW){ 
	if (sPW.length<=9) return 1; 
	Modes=1; 
	for (i=0;i<sPW.length;i++){ 
		Modes|=CharMode(sPW.charCodeAt(i)); 
	} 
	return bitTotal(Modes); 
} 
var  S_level;
function pwStrength(pwd){
	//debugger;
	if($("#newPassword").val() != ""){
		var reg=/^[A-Za-z0-9~`!@#$%^&*()_+\'{}<>?:,.;-=\"]+$/;
	    if(!reg.test($("#newPassword").val())){
    		$("#newPasswordShowEm").html("密码不允许使用空格！");
    	}else{
    		$("#newPasswordShowEm").html("");
	    }
	}
	if($("#repeatNewPassword").val() != ""){
		onRepeatNewPasswordMouseMove();
	}
	if(loginStatusPwd == 2){
		hiddenTable();
	}
	$("#hiddenTable").attr("style","");
	if (pwd==null||pwd==''){ 
		S_level = 0;
	}else {
		S_level=checkStrong(pwd); 
		//alert(S_level); 
		switch(S_level) { 
		case 0: ; 
		case 1: $("#strength_L").addClass("cur"); $("#strength_M").attr("class","m");$("#strength_H").attr("class","h"); 
		break; 
		case 2: $("#strength_M").addClass("cur"); $("#strength_L").attr("class","l");$("#strength_H").attr("class","h"); 
		break; 
		default: 
			$("#strength_H").addClass("cur"); $("#strength_M").attr("class","m");$("#strength_L").attr("class","l"); 
		} 
	}
	return ; 
} 

//新确密码相同提示
function onRepeatNewPasswordMouseMove() {
	if($("#newPassword").val() != "" &&　$("#repeatNewPassword").val() != ""){
	if ($("#newPassword").val() != $("#repeatNewPassword").val()) {
		$("#repeatPasswordShow1").html("新密码与确认密码不一致");
	} else {
		$("#repeatPasswordShow1").html("");
	}
	}
}
function hiddenTable(){
	if($("#newPassword").val().length > 16 ){
		$("#newPasswordShowEm").html("密码长度是16位以内！");
	}else{
		$("#newReviewPasswordShowEm").html("");
		if(S_level < pwdLevel && S_level > 0){
    		var msg = "";
    		if(pwdLevel == 2) msg="密码强度是中以上！";
    		if(pwdLevel == 3) msg="密码强度是强以上！";
    		$("#newPasswordShowEm").html(msg);
    	}else{
    		$("#newPasswordShowEm").html("");
    		$("#hiddenTable").hide();
    	}
	}
	if($("#newPassword").val() != ""){
		if($("#newPassword").val() == $("#password").val()){
			$("#newPasswordShowEm").html("新密码与原密码不能相同！");
    	}else{
    		var reg=/^[A-Za-z0-9~`!@#$%^&*()_+\'{}<>?:,.;-=\"]+$/;
		    if(!reg.test($("#newPassword").val())){
	    		$("#newPasswordShowEm").html("密码不允许使用空格！");
	    	}
    	}
	}
}
function onPasswordMouseMove(){
    if($("#password").val() != ""){
    	if($("#newPassword").val() == $("#password").val()){
    		$("#newPasswordShowEm").html("新密码与原密码不能相同！");
    	}else{
    		$("#newPasswordShowEm").html("");
    	}
    }
}

function passwordblur(){
	debugger;
	if($("#password").val() != ""){
	var realpwd = $('#realpwd').val();
	var password = md5(md5($("#password").val()));
	if(realpwd != password){
		$('#PasswordShowEm').html("原密码输入错误！");
	}else{
		$('#PasswordShowEm').html("");
	}
	}
}
function repeatNewPasswordfocus(){
	$("#repeatPasswordShow1").html("");
}
function passwordfocus(){
	$('#PasswordShowEm').html("");
}
// 校验登录密码


function showLoginPwdDivTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action',
	         active:true
			}
		);
}
function showReviewPwdDivTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action?type=2',
	         active:true
			}
		);
}
function showPersonalDataTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action?type=3',
	         active:true
			}
		);
}

function changeDivContent() {
	if ($("#reviewPwdHidden").val() == "") {
		$("#reviewPwdDiv").html($("#setReviewPwdDiv").html());
		$("#setReviewPwdDiv").html("");
	}
}
changeDivContent();
</script>
